﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DevExpress.Utils.Drawing.Helpers;
using RR;

public partial class Default2 : System.Web.UI.Page
{
    private RegistRar regrar = new RegistRar();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["issuedocdata"] != null)
        {
            grid.DataSource = Session["issuedocdata"];
            grid.DataBind();
            grid.ExpandAll();
        }
    }
    protected void btnExec_Click(object sender, EventArgs e)
    {
        GetData();
    }

    private void GetData()
    {
        var query = (from d in regrar.DOGDOC
                     where d.ARCPLACE1.STATE == 2 | d.ARCPLACE1.STATE == 3
                     select new
                     {
                         d.ARCPLACE,
                         d.ARCPLACE1.STRCODE,
                         d.ARCPLACE1.ARCRACK1.ARCROOM1.ARCOBJECT,
                         OBJNAME = d.ARCPLACE1.ARCRACK1.ARCROOM1.ARCOBJECT1.NAME,
                         ROOMNAME = d.ARCPLACE1.ARCRACK1.ARCROOM1.NOTE,
                         RACKNAME = d.ARCPLACE1.ARCRACK1.NOMER,
                         d.ARCPLACE1.SHELF,
                         d.ARCPLACE1.CELL,
                         d.ARCPLACE1.NUMBER,
                         d.ARCPLACE1.WORKER,
                         WORKERNAME = d.ARCPLACE1.WORKER1.FIO,
                         d.ARCPLACE1.ORDERDOC,
                         //d.DATA,
                         d.DOGDOP.DOG1.KONTRAGENT,
                         KONTR = d.DOGDOP.DOG1.KONTRAGENT1.NAME,
                         d.ARCPLACE1.STATE
                     });

       // if (dt1.Value != null) { query = query.Where(d => d.DATA >= dt1.Date); }
       // if (dt2.Value != null) { query = query.Where(d => d.DATA <= dt2.Date); }
        if (cbb_kontr.Value != null)
        {
            int kontr = Convert.ToInt32(cbb_kontr.Value);
            query = query.Where(d => d.KONTRAGENT == kontr);
        }
        if (cbb_user.Value != null)
        {
            int _worker = Convert.ToInt32(cbb_user.Value);
            query = query.Where(d => d.WORKER == _worker);
        }
        if (cbb_object.Value != null)
        {
            int _object = Convert.ToInt32(cbb_object.Value);
            query = query.Where(d => d.ARCOBJECT == _object);
        }

        Session["issuedocdata"] = query.Distinct().ToList();

        grid.DataSource = Session["issuedocdata"];
        grid.DataBind();
        grid.ExpandAll();
    }

}